package com.sample.rx3;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

public class ViewPager2Adapter extends FragmentStateAdapter {
    private final List<Fragment> tList;

    public ViewPager2Adapter(@NonNull FragmentActivity fragmentActivity, List<Fragment> tList) {
        super(fragmentActivity);
        this.tList = tList;
    }

    public ViewPager2Adapter(@NonNull Fragment fragment, List<Fragment> tList) {
        super(fragment);
        this.tList = tList;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return tList.get(position);
    }

    @Override
    public int getItemCount() {
        return tList.size();
    }
}
